package com.zjs.contorller;

import java.util.Random;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestContorller {
	
	@GetMapping("/testC")
	public String testC() {
		return randomlyRunLong();
	  }
	private String randomlyRunLong() {
		Random rand = new Random();

		int randomNum = rand.nextInt(2) + 1;

		if (randomNum == 2) {
			sleep();
			return " C服务休眠3s";
		}
		return "C服务无休眠";
	}

	private void sleep() {
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
}
